import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { LoginData, LoginResult } from './types';

/**
 *
 * @param data {LoginForm}
 * @returns
 */
export function loginCoceApi(data: any) {
  return request({
    url: '/api/plat/user/loginByPhoneCode', // /system/admin/login
    method: 'post',
    data: data,
    // headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' },
  });
}

/**
 * 获取验证码
 *
 * @param data
 * @returns
 */
export function getReturncode(data: any) {
  return request({
    url: '/api/sys/user/returncode',
    method: 'post',
    data
  });
}

/**
 * 登录API
 *
 * @param data {LoginData}
 * @returns
 */
export function loginApi(data: any) {
  return request({
    url: '/api/sys/user/login', // /api/sys/user/login  /api/sys/user/phone/login
    method: 'post',
    data
  });
}

/**
 * 注销API
 */
export function logoutApi(data = {}) {
  return request({
    url: '/api/sys/user/logout',
    method: 'post',
    data
  });
}
